home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1996 February / PC Direct CD-ROM (February 1996).iso / remove / remove.rul < prev   
Text File  |  1995-08-18  |  19KB  |  524 lines

  1. // ----------------------------------------------------------------------
  2. // Copyright ⌐ 1995, National Education Training Group, Inc.            -
  3. // All rights reserved.                                                 -
  4. //                                                                      -
  5. // Skill Builder 4.01 Course Removal                  by Carol Townsend -
  6. //-----------------------------------------------------------------------
  7.  
  8. //-----------------------------------------------------------------------
  9. //      Set predefined constants.                                       -
  10. //-----------------------------------------------------------------------
  11.  
  12. #define MAX_SIZE         255
  13.  
  14. declare // Must use declare keyword to start variable declaration
  15.  
  16. string  szText[256], szDisk[20], DelCourse[10], szBitmapPath[50],
  17.     szResultPath[MAX_SIZE], szTitle[50], svCmdLine[MAX_SIZE], 
  18.     szItemName[150], szErrFile[MAX_SIZE], szWinDirectory[144], 
  19.     szTotal[20], szDefPath[50], szRemove[25], szResult[10], 
  20.     szDelDir[MAX_SIZE], NameNum[10], szCount[3], OldCourse[10],
  21.     szCommandLine[MAX_SIZE], szCommandLine2[MAX_SIZE], svDisk[5], 
  22.     svWrkDir[MAX_SIZE], svIconPath[MAX_SIZE], svShortCutKey[50], 
  23.     szSBDir[25], szWinINI[144], szUserPath[80], szUserFile[10],
  24.     szVersion[10], szMediaType[10], szMessageFile [50];
  25.      
  26. INT bFound  // Flag  is set when DelCourse is found in course section
  27.             // of NETG.INI.  This prevents lost courses if remove
  28.             // is run more than once for a 4.0 CD course. 
  29.                  
  30. number  nTotal, nnew, nvIconIndex, nCount, nvMinimizeFlag;
  31. LONG    lResult;
  32. LIST    listID;
  33.  
  34. program /* Must use program keyword to start the statements */
  35.  
  36.  
  37. Start:
  38.     GetDisk ( SRCDIR, svDisk );
  39. //    szBitmapPath = svDisk ^ "INSTALL";
  40. //    szBitmapPath = szBitmapPath ^ "NETGLOG8.BMP";
  41. //    PlaceBitmap( szBitmapPath, 101, 20, 20, UPPER_RIGHT );
  42.  
  43.     szBitmapPath = SUPPORTDIR ^ "NETGLOG8.BMP";
  44.     szMessageFile = SUPPORTDIR ^ "MESSAGES.INI";
  45.     PlaceBitmap( szBitmapPath, 1, CENTERED, CENTERED, CENTERED );
  46.  
  47.     SetColor( BACKGROUND, RGB(255,255,255) );
  48.  
  49.  
  50.     // Set the color of the background to be BLUE
  51.     //SetColor( BACKGROUND, RGB( 0,0,255 ) );
  52.     SetColor( STATUSBAR, RED );
  53.     SetFont( FONT_TITLE, STYLE_NORMAL, "Helv" );
  54.     Enable( BACKGROUND );
  55.     //Enable( STATUS );
  56.        
  57.     szTitle = "Skill Builder « Removal";
  58.     SetTitle( szTitle, 18, WHITE );
  59.     SetStatusWindow( 1, szTitle );
  60.        
  61.     // In Info Window to display the file1.lis
  62.     SetInfoWindow( "Information ", "file1.lis" );
  63.  
  64.     // Enable various objects.
  65.     Disable( HELP );        //
  66.     Enable( EXIT );         // Exit Button
  67.     Disable( PAUSE );       // Pause Button
  68.     //Enable( TEXT );         // Info Windows
  69.     Disable( STATUS );       // Status , % Complete Bar Window
  70.     Disable( TEXT );         // Info Windows
  71.     Disable( FEEDBACK_FULL); // Feedback window enabled
  72.  
  73.  
  74.     GetSystemInfo(VIDEO, nvIconIndex, svWrkDir);
  75.     if ((nvIconIndex = IS_UVGA) | (nvIconIndex = IS_UNKNOWN)) then
  76.         PlaceWindow( STATUS, 300, 70, LOWER_RIGHT);
  77.     elseif (nvIconIndex = IS_XVGA) then
  78.         PlaceWindow( STATUS, 250, 30, LOWER_RIGHT);
  79.     else
  80.        PlaceWindow( STATUS, CENTERED, CENTERED, CENTERED);
  81.     endif;
  82.  
  83.  
  84. //---------------------------------------------------------------------
  85. //         This procedure accepts the Course Number from user         -
  86. //---------------------------------------------------------------------
  87. COURSENUM:
  88.     szResultPath = svDisk ^ "INSTALL" ^ "INSTALL.INI";
  89.     if (GetProfString (szResultPath, "course", "number", DelCourse) != 0) then
  90.        goto BadInstallINI;
  91.     endif;   
  92.     if (GetProfString (szResultPath, "install", "ver", szVersion) != 0) then
  93.        goto BadInstallINI;
  94.     endif;   
  95.     if (GetProfString (szResultPath, "install", "type", szMediaType) != 0) then
  96.        goto BadInstallINI;
  97.     endif;   
  98.     StrToUpper (szMediaType, szMediaType);
  99.     
  100.     if ((szVersion < "4.0") | (szMediaType != "CD")) then
  101.        SetDialogTitle( DLG_ASK_TEXT,  "Enter course number" );
  102.        szText = "Please enter the course number \nyou wish to remove. ";
  103.        DelCourse = "";
  104.        AskText( szText, DelCourse, DelCourse );
  105.        if LAST_RESULT = FALSE then
  106.           goto ConfirmCancel;
  107.        endif; 
  108.     else
  109.        Enable(STATUS);
  110.        SetStatusWindow (20, szTitle);            
  111.     endif;   
  112.  
  113. //---------------------------------------------------------------------
  114. //           This procedure gets the Disk letter from NETG.INI and    -
  115. //             defines the course and SB sub-directories.             -
  116. //---------------------------------------------------------------------
  117. TARGETLOC:
  118.  
  119.  
  120.     FindFile( WINDIR, "NETG.INI", szResult );
  121.     if LAST_RESULT != 0
  122.     then
  123.       call MISSING_INI;
  124.     endif;
  125.  
  126.     //-----------------------------------------------------------------
  127.     //     Defines a path to the NETG.INI file using a variable       -
  128.     //-----------------------------------------------------------------
  129.     szWinDirectory = WINDIR;
  130.     szWinDirectory = szWinDirectory ^ "NETG.INI";
  131.        
  132.  
  133.     GetProfString( szWinDirectory, DelCourse, "Path", szDefPath );
  134.     szDefPath = szDefPath ^ "\\";
  135.  
  136.  
  137.     GetDisk( szDefPath, szDisk );
  138.     szDefPath = szDefPath ^ "SKILLB";
  139.     szSBDir = szDefPath;
  140.     szDefPath = szDefPath ^ DelCourse;
  141.        
  142.     if ((szVersion > "4.0") & (szMediaType = "CD")) then
  143.        SetStatusWindow (40, szTitle);
  144.        call CheckCD40LM;
  145.        szDelDir = szDefPath;
  146.        SetStatusWindow (60, szTitle);
  147.        goto NETGINI;
  148.     else   
  149.        ExistsDir( szDefPath );
  150.        if LAST_RESULT = EXISTS then
  151.           goto REMOVECOURSE;
  152.        endif;
  153.  
  154.        szText = "Course, ";
  155.        szText = szText + DelCourse;
  156.        szText = szText + ", does not exist on this system.\nPress OK to return to the course selection.";
  157.        MessageBox( szText, WARNING );
  158.        szDefPath = "";  // Reset Default path
  159.        goto COURSENUM;
  160.     endif;
  161.  
  162.  
  163. //---------------------------------------------------------------------
  164. //     This procedure removes all course files & sub-directories      -
  165. //---------------------------------------------------------------------
  166.  
  167. REMOVECOURSE:
  168.  
  169.     Enable( STATUS );       // Status , % Complete Bar Window
  170. //    Enable( TEXT );         // Info Windows
  171.     Enable( FEEDBACK_FULL); // Feedback window enabled
  172.  
  173.     GetProfString( szWinDirectory, DelCourse, "UserPath", szUserPath );
  174.  
  175.     if (szUserPath = szDefPath ^ "PRESENT" | szUserPath = szDefPath ^ "ICONWARE"
  176.     | szUserPath = szDefPath | szUserPath = szDefPath ^ "PICS_ENU" 
  177.     | szUserPath = szDefPath ^ "INPUT" | szUserPath = szDefPath ^ "INPUT"
  178.     | szUserPath = szDefPath ^ "VAR_ENU" | szUserPath = szDefPath ^ "TEXT_ENU" )
  179.     then
  180.       SetInfoWindow( "Information ", "file2.lis" );
  181.       SetDialogTitle( DLG_ASK_YESNO, "Delete Learner Management Files" );
  182.       AskYesNo ("Learner Management files have been installed in the coures subdirectory.  Are you sure that you want to remove the course with these files?", NO );
  183.       if ( LAST_RESULT = NO )
  184.       then
  185.         szText = "To save Learner Management files, move these files to a non-course directory.  The files are currently in the ";
  186.         szText = szText + szUserPath;
  187.         szText = szText + "\ directory.";
  188.         MessageBox (szText, INFORMATION);
  189.         exit; 
  190.       endif;
  191.     endif;
  192.  
  193.     SetInfoWindow( "Information ", "file1.lis" );
  194.     ChangeDirectory( szDisk ^ "\\" ); // Allows removal if user is in
  195.                       // course directory.
  196.  
  197.     szDelDir = szDefPath;
  198.     szDefPath = szDefPath ^ "PRESENT"; 
  199.     SetStatusWindow( 15, "Removing PRESENT" );
  200.     DeleteDir( szDefPath, ALLCONTENTS );
  201.     ExistsDir( szDefPath );
  202.     if LAST_RESULT = EXISTS
  203.     then
  204.       goto BAD_REMOVE;
  205.     endif;
  206.  
  207.     szDefPath = szDelDir;
  208.     szDefPath = szDefPath ^ "ICONWARE";
  209.     SetStatusWindow( 30, "Removing ICONWARE" );
  210.     DeleteDir( szDefPath, ALLCONTENTS );
  211.     ExistsDir( szDefPath );
  212.     if LAST_RESULT = EXISTS
  213.     then
  214.       goto BAD_REMOVE;
  215.     endif;
  216.  
  217.     szDefPath = szDelDir;
  218.     szDefPath = szDefPath ^ "PICS_ENU";
  219.     SetStatusWindow( 45, "Removing GRAPHICS" );
  220.     DeleteDir( szDefPath, ALLCONTENTS );
  221.     ExistsDir( szDefPath );
  222.     if LAST_RESULT = EXISTS
  223.     then
  224.       goto BAD_REMOVE;
  225.     endif;
  226.  
  227.     szDefPath = szDelDir;
  228.     szDefPath = szDefPath ^ "INPUT";
  229.     SetStatusWindow( 60, "Removing INPUT" );
  230.     DeleteDir( szDefPath, ALLCONTENTS );
  231.     ExistsDir( szDefPath );
  232.     if LAST_RESULT = EXISTS
  233.     then
  234.       goto BAD_REMOVE;
  235.     endif;
  236.  
  237.     szDefPath = szDelDir;
  238.     szDefPath = szDefPath ^ "VAR_ENU";
  239.     SetStatusWindow( 65, "Removing VAR_ENU" );
  240.     DeleteDir( szDefPath, ALLCONTENTS );
  241.     ExistsDir( szDefPath );
  242.     if LAST_RESULT = EXISTS
  243.     then
  244.       goto BAD_REMOVE;
  245.     endif;
  246.  
  247.     szDefPath = szDelDir;
  248.     szDefPath = szDefPath ^ "TEXT_ENU";
  249.     SetStatusWindow( 70, "Removing TEXT_ENU" );
  250.     DeleteDir( szDefPath, ALLCONTENTS );
  251.     ExistsDir( szDefPath );
  252.     if LAST_RESULT = EXISTS
  253.     then
  254.       goto BAD_REMOVE;
  255.     endif;
  256.  
  257.     szDefPath = szDelDir;
  258.     szText = "Removing course sub-directory ";
  259.     szText = szText + DelCourse;
  260.     SetStatusWindow( 95, szText );
  261.     DeleteDir( szDefPath, ALLCONTENTS );
  262.     ExistsDir( szDefPath );
  263.     if LAST_RESULT = EXISTS
  264.     then
  265.       goto BAD_REMOVE;
  266.     endif;
  267.  
  268. //----------------------------------------------------------------------
  269. //      Delete VSI batch file for running the course.
  270. //----------------------------------------------------------------------
  271.  
  272.     TARGETDIR = "C:\\";
  273.     DeleteFile ( DelCourse + ".BAT" );
  274.  
  275. //----------------------------------------------------------------------
  276. //      Updates NETG.INI file - if this is the last course on the      -
  277. //      system, NETG.INI and the SB movie are deleted.                 -
  278. //----------------------------------------------------------------------
  279.  
  280.     SetStatusWindow( 98, "Updating NETG.INI" );
  281.     
  282. NETGINI:
  283.     
  284.     GetProfInt( szWinDirectory, "Course", "Total", nTotal );
  285.     
  286.     bFound = FALSE;
  287.     
  288.     if nTotal = 1 then
  289.     
  290.     //delete NETG.INI, Skill Builder Movie, and the Icon Sounds 
  291.     
  292.     //7/31/95  moved deletion of movie and wav files to next 'if'
  293.     //         to prevent drive read errors for CD 4.0 removals. 
  294.     
  295.        TARGETDIR = WINDIR;
  296.        DeleteFile( "NETG.INI" );
  297.        
  298.     //delete NETG sounds from WIN.INI
  299.        szWinINI = WINDIR ^ "WIN.INI";
  300.        WriteProfString (szWinINI, "Sounds", "NETGRewind", "" );
  301.        WriteProfString (szWinINI, "Sounds", "NETGForward", "" );
  302.        WriteProfString (szWinINI, "Sounds", "NETGFForward", "" );
  303.        WriteProfString (szWinINI, "Sounds", "NETGMap", "" );
  304.        WriteProfString (szWinINI, "Sounds", "NETGExit", "" );
  305.        WriteProfString (szWinINI, "Sounds", "NETG4Rewind", "" );
  306.        WriteProfString (szWinINI, "Sounds", "NETG4Forward", "" );
  307.        WriteProfString (szWinINI, "Sounds", "NETG4FForward", "" );
  308.        WriteProfString (szWinINI, "Sounds", "NETG4Map", "" );
  309.        WriteProfString (szWinINI, "Sounds", "NETG4Exit", "" );
  310.       
  311.        if ((szVersion > "4.0") & (szMediaType = "CD")) then
  312.           szText = "This is the last Skill Builder course on your system.  Do you want to delete the program group from Windows?";
  313.           if ( AskYesNo (szText, YES) = YES ) then
  314.              DeleteGroup ("NETG SB Courseware");
  315.           endif;
  316.        else
  317.           TARGETDIR = szSBDir;
  318.           DeleteFile ( "SBMOVIE*.FLI" );
  319.           DeleteFile ( "*.WAV" );
  320.           call Delete_SB_Directory;
  321.        endif;
  322.     else
  323.       nnew = 1;
  324.       for nCount = 1 to nTotal
  325.          NameNum = "Name";
  326.          NumToStr( szCount, nCount );       // Build NAMEn Keyname
  327.          NameNum = NameNum + szCount;
  328.          GetProfString( szWinDirectory, "Course", NameNum, OldCourse );
  329.  
  330.          StrCompare( OldCourse, DelCourse );  // Course to Delete ?
  331.          if LAST_RESULT = 0 then
  332.                     // Delete course entry from Course App. Section NETG.INI
  333.             WriteProfString( szWinDirectory, "Course", NameNum, "" );
  334.             bFound = TRUE;
  335.          else
  336.             NameNum = "Name";
  337.             NumToStr( szCount, nnew );       // Build new NAMEn Keyname
  338.             NameNum = NameNum + szCount;
  339.             WriteProfString( szWinDirectory, "Course", NameNum, OldCourse );
  340.             nnew = nnew + 1;
  341.          endif;
  342.       endfor;
  343.       
  344.       if bFound = TRUE then
  345.          NameNum = "Name";
  346.          NumToStr( szCount, nTotal );           // Delete Extra NAMEn Keyname
  347.          NameNum = NameNum + szCount;
  348.          WriteProfString( szWinDirectory, "Course", NameNum, "" );
  349.       endif;   
  350.          
  351.       // Delete Course Specific area from NETG.INI
  352.       WriteProfString( szWinDirectory, DelCourse, "", "");
  353.       WriteProfString( szWinDirectory, "Course", "Total", "" );
  354.       
  355.       if bFound = TRUE then
  356.          nTotal = nTotal - 1;
  357.       endif;
  358.       NumToStr( szTotal, nTotal );
  359.       if LAST_RESULT = 0
  360.       then
  361.          WriteProfString( szWinDirectory, "Course", "Total", szTotal );
  362.       else
  363.          MessageBox("Missing or corrupted NETG.INI,\n You must reinstall all skill builder courseware for proper execution", INFORMATION);
  364.       endif;
  365.     endif;
  366.  
  367. //---------------------------------------------------------------------
  368. //            Check for removal of course
  369. //---------------------------------------------------------------------
  370.  
  371.     if ((szVersion < "4.0") | (szMediaType != "CD")) then
  372.        GetDisk( szDefPath, szDisk );
  373.        ExistsDir( szDelDir );
  374.        if LAST_RESULT = EXISTS then
  375.           goto BAD_REMOVE;
  376.        endif; 
  377.     else
  378.        SetStatusWindow (80, szTitle);   
  379.     endif;   
  380.  
  381. //---------------------------------------------------------------------
  382. //            Remove course icon from NETG SB Courseware group
  383. //---------------------------------------------------------------------
  384.  
  385.  
  386.     szCommandLine = szDelDir ^ "PRESENT\\PRESENT";
  387.     szCommandLine = szCommandLine + " ";
  388.     szCommandLine = szCommandLine + szDelDir;
  389.     szCommandLine = szCommandLine ^ "ICONWARE";
  390.     szCommandLine = szCommandLine ^ DelCourse;
  391.     szCommandLine = szCommandLine + ".IW";
  392.  
  393.     szCommandLine2 = szDelDir ^ "PRESENT\\PRESENT";
  394.     szCommandLine2 = szCommandLine2 + " ..";
  395.     szCommandLine2 = szCommandLine2 ^ "ICONWARE";
  396.     szCommandLine2 = szCommandLine2 ^ DelCourse;
  397.     szCommandLine2 = szCommandLine2 + ".IW";
  398.  
  399.     listID = ListCreate( STRINGLIST );
  400.     
  401.     GetItemNameList ("NETG SB Courseware", listID );
  402.     if (ListGetFirstString( listID,szItemName ) != END_OF_LIST)
  403.     then
  404.       QueryProgItem( "NETG SB Courseware", szItemName, svCmdLine, svWrkDir, svIconPath, nvIconIndex, svShortCutKey, nvMinimizeFlag );
  405.       if szCommandLine = svCmdLine
  406.       then
  407.         call DeleteIcon;
  408.       endif;
  409.       if szCommandLine2 = svCmdLine
  410.       then
  411.         szCommandLine2 = szCommandLine;
  412.         call DeleteIcon;
  413.       endif;
  414.       while (lResult != END_OF_LIST )
  415.         lResult = ListGetNextString( listID, szItemName );
  416.         QueryProgItem( "NETG SB Courseware", szItemName, svCmdLine, svWrkDir, svIconPath, nvIconIndex, svShortCutKey, nvMinimizeFlag );
  417.         if szCommandLine = svCmdLine then
  418.           
  419. //      MessageBox (szItemName, INFORMATION);  
  420.  
  421.            call DeleteIcon;
  422.         elseif szCommandLine2 = svCmdLine then
  423.                call DeleteIcon;
  424.         endif;    
  425.       endwhile;
  426.     endif;
  427.  
  428.     ListDestroy (listID);
  429.     
  430.     Delay( 3 ); //Artificial Delay
  431.     SetStatusWindow( 100, "Removal Complete" );
  432.     MessageBox( "Removal complete.\nPress OK to exit.", INFORMATION );
  433.     goto EXIT_IT;
  434.  
  435. BAD_REMOVE:
  436.  
  437.     MessageBox( "Removal did not complete correctly.\n Please Check for courseware files.", SEVERE );
  438.     goto EXIT_IT;
  439.  
  440. MISSING_INI:
  441.  
  442.     MessageBox( "Missing NETG.INI,\n You must reinstall all Skill Builder courseware for proper execution", INFORMATION);
  443.     goto EXIT_IT;
  444.  
  445. BadInstallINI:
  446.  
  447.     MessageBox( "There is a problem with the INSTALL.INI file. Course has not been removed.", SEVERE);
  448.     goto EXIT_IT;
  449.  
  450. EXIT_IT:                               
  451.  
  452.     exit;  //Exit removal program.
  453.  
  454. //---------------------------------------------------------------------
  455. //        This procedure will confirm with the users if they          -
  456. //           want to terminate the removal of the course.             -
  457. //---------------------------------------------------------------------
  458. ConfirmCancel:
  459.  
  460.     AskYesNo( "Are you sure you want to CANCEL Remove?", FALSE );
  461.  
  462.     if LAST_RESULT = FALSE
  463.     then
  464.       goto COURSENUM;
  465.     endif;
  466.     exit;
  467.  
  468. DeleteIcon:
  469.  
  470.     ShowGroup( "NETG SB Courseware", SW_SHOWMINNOACTIVE );
  471.     ShowGroup( "NETG SB Courseware", SW_NORMAL );
  472.     DeleteProgItem ( "NETG SB Courseware", szItemName, ""); 
  473.     return;
  474.  
  475. Delete_SB_Directory:
  476.  
  477.  
  478.     szText = "This is the last Skill Builder course on your system.  Do you want to delete all the files in the Skill Builder directory and the program group from Windows?";
  479.  
  480.     if ( AskYesNo( szText, YES) = NO )
  481.     then
  482.       return;
  483.     else
  484.       DeleteGroup ("NETG SB Courseware");
  485.  
  486.       if (FindFile( szSBDir, "NE_USERS.FMT", szText ) = 0)
  487.       then
  488.         szText = "Learner Management files were found in the Skill Builder directory.  Do you wish to leave the directory with these files?";
  489.  
  490.         if ( AskYesNo( szText, YES) = YES )
  491.         then
  492.           return;
  493.         endif;
  494.       endif;  
  495.  
  496.       DeleteDir (szSBDir, ALLCONTENTS );
  497.     endif;
  498.     return;
  499.  
  500. CheckCD40LM:
  501.  
  502.     GetProfString (szWinDirectory, DelCourse, "UserPath", szUserPath);
  503.     
  504.     CopyBytes (szText, 0, DelCourse, 0, 2);
  505.     szUserFile = "000" + szText;
  506.     szUserFile = szUserFile + ".";
  507.     CopyBytes (szText, 0, DelCourse, 2, 3);
  508.     szUserFile = szUserFile + szText;
  509.     
  510.     if (FindFile (szUserPath, szUserFile, szResult) = 0) then
  511.        SetDialogTitle (DLG_ASK_YESNO, "Delete Learner Management Files");
  512.        AskYesNo ("Do you want to delete the Learner Management File for the course?", NO);
  513.        if LAST_RESULT = YES then
  514.           TARGETDIR = szUserPath;
  515.           DeleteFile (szUserFile);
  516.        endif;
  517.     endif;
  518.     return;             
  519.     
  520. // ----------------------------------------------------------------------
  521. //      Copyright 1995 - National Education Training Group              -
  522. //      Skill Builder Course Removal                                    -                                                                    
  523. //-----------------------------------------------------------------------
  524.